import mpx, { createPage } from "@mpxjs/core";
import util from "~/utils/util";

const app = getApp();
const pageSize = 10; // 分页大小

createPage({
  data: {
    list: [],
    page: 1,
    loading: false,
    finished: false,
    rid: "",
    cityId: "",
    listData: [],
    cityList:[],
    isScrollY: true,
    filterHeight: 100,
  },
  onLoad(options) {
    this.rid = options.rid;
    this.init();
  },
  async init() {
    let citylist = await util.getCityList();

  },    //获取城市列表
  async _getCityListData(){
    try {
      console.log(3434343)
      const res = await util.getData(
        `${'client/douyin/cities'}?rid=${this.rid}`,
      );
    return res;
    } catch (error) {

    }
  },
  //获取职位列表
  async _getCityListData(){
    try {
      console.log(3434343)
      const res = await util.getData(
        `${'client/douyin/lists'}?rid=${this.rid}&=city_id=${this.cityId}`,
      );
    return res;
    } catch (error) {

    }
  },
  onReachBottom() {
    this.getData();
  },
  async getData() {
    if (this.data.loading || this.data.finished) return;
    this.setData({ loading: true });
    const res = await mpx.request({
      url: "https://api.apiopen.top/getJoke",
      data: {
        page: this.data.page,
        count: pageSize,
        type: "video",
      },
    });
    const list = res.data.result;
    if (list.length < pageSize) {
      this.setData({ finished: true });
    }
    this.setData({
      list: this.data.list.concat(list),
      page: this.data.page + 1,
      loading: false,
    });
  },
});
